- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
          Add more cases to the useless_conversion lint
          #13756
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
84c317b    to
    107ceb8      
    Compare
  
    | The hits in lintcheck are true positives. | 
159742f    to
    eac1e50      
    Compare
  
    | Lookup code will be simplified when rust-lang/rust#133686 is merged and synchronized with Clippy. | 
The new cases are `x.map(f)` and `x.map_err(f)` when `f` is `Into::into` or `From::from` with the same input and output types.
723b9a6    to
    856aa03      
    Compare
  
    | return true; | ||
| } | ||
|  | ||
| // Necessary for `core::ops::control_flow::ControlFlow` until a diagnostic item | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add FIXME: Add ControlFlow diagnostic item, so that in the future we can add necessary diagnostic items in masse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. My PR has been merged into rust-lang so we should get it at the next sync.
| return true; | ||
| } | ||
| } | ||
| if is_trait_method(cx, expr, sym::Iterator) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to lint for any methods of Iterator? What would the use case for this branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only activates for the recognized methods (map_*), no other methods of Iterator will trigger that.
856aa03    to
    0b867cf      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! ❤️
Could you squash that third commit into the second one?
- `ControlFlow::map_break()` - `ControlFlow::map_continue()` - `Iterator::map()`
0b867cf    to
    ab5d55c      
    Compare
  
    | 
 Done | 
The new cases are the application of
Into::intoorFrom::fromthrough the following functions with no effect:Option::map()Result::map()andResult::map_err()ControlFlow::map_break()andControlFlow::map_err()Iterator::map()changelog: [
useless_conversion]: detect useless calls toInto::intoandFrom::fromapplication throughmap*methods